import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '../views/index.vue'
import detail from '../views/detail.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/index',
    name: 'index',
    redirect:'/index/main',
    component: index,
    children:[
      {
        path: '/index/main',
        name: 'main',
        component: () => import( '../views/indexchild/main.vue')
      },
      {
        path: '/index/mine',
        name: 'mine',
        component: () => import( '../views/indexchild/mine.vue')
      },
      {
        path: '/index/shopcar',
        name: 'shopcar',
        component: () => import( '../views/indexchild/shopcar.vue')
      },
    ]
  },
  {
    path: '/detail',
    name: 'detail',
    component: detail
  },
  {
    path: '*',
    redirect:'/index/main'
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
